#pragma once
#include "RBTree.h"

namespace bit
{
    template <class K>
    class MySet
    {
        struct KeyOfValue
        {
            const K& operator()(const K& key) const
            {
                return key;
            }
        };

    public:
        typedef RBTree<K, K, KeyOfValue> RBTreeType;
        typedef typename RBTreeType::Iterator iterator;
        typedef typename RBTreeType::ConstIterator const_iterator;

        iterator begin()
        {
            return _rbTree.Begin();
        }

        iterator end()
        {
            return _rbTree.End();
        }

        const_iterator begin() const
        {
            return _rbTree.Begin();
        }

        const_iterator end() const
        {
            return _rbTree.End();
        }

        bool Insert(const K& key)
        {
            return _rbTree.Insert(key).second;
        }

        iterator Find(const K& key)
        {
            return _rbTree.Find(key);
        }

        bool Erase(const K& key)
        {
            return _rbTree.Erase(key);
        }

        size_t Size() const
        {
            return _rbTree.Size();
        }

        bool Empty() const
        {
            return _rbTree.Empty();
        }

        void Preorder() const
        {
            _rbTree.Preorder();
        }

        void Inorder() const
        {
            _rbTree.Inorder();
        }

        void Postorder() const
        {
            _rbTree.Postorder();
        }

    private:
        RBTreeType _rbTree;
    };
}
